import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
const state = {
  isAuthenticated: false,//是否认证
  user: {},
  profile: {},//用来存储用户个人信息
  loading: false,
  profiles: {}
}

export default new Vuex.Store({
  state,
  getters: {
    isAuthenticated: (state) => { return state.isAuthenticated },
    user(state) { return state.user },
    profile(state) { return state.profile },
    loading(state) { return state.loading },
    profiles(state) { return state.profiles },

  },
  mutations: {
    setUser(state, data) { state.user = data },
    setIsAuthenticated(state, data) { state.isAuthenticated = data },
    setProfile(state, data) { state.profile = data },
    setLoading(state, data) { state.Loading = data },
    setProfiles(state, data) { state.profiles = data },



  },
  actions: {
    setUser({ commit }, data) {
      commit('setUser', data)
    },
    setIsAuthenticated({ commit }, data) {
      commit('setIsAuthenticated', data)
    },
    setProfile({ commit }, data) {
      commit('setProfile', data)
    },
    setLoading({ commit }, data) {
      commit('setLoading', data)
    },
    setProfiles({ commit }, data) {
      commit('setProfiles', data)
    },
  }
})
